﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Script.Serialization;
using System.Web.Services;

/// <summary>
/// Summary description for MazeGenerator
/// </summary>
[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
// To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line. 
// [System.Web.Script.Services.ScriptService]
public class MazeGenerator : System.Web.Services.WebService {

    public MazeGenerator () {

        //Uncomment the following line if using designed components 
        //InitializeComponent(); 
    }

    [WebMethod]
    public string HelloWorld() {

        return "Hello World";
    }

    /// <summary>
    /// Return the generated maze data as json strings
    /// </summary>
    /// <param name="height"></param>
    /// <param name="width"></param>
    /// <returns></returns>
    [WebMethod(Description="Get the maze data as json string")]
 
    public string GenerateNewMaze_Json(int height, int width) {
        MazeDataGen gen=new MazeDataGen(height,width);
        JavaScriptSerializer objSerializer=new JavaScriptSerializer();
        return objSerializer.Serialize(gen.GenerateNewMaze());
    }

    [WebMethod(Description = "Get the maze data as xml")]
    public Cell[] GenerateNewMaze_XML(int height, int width)
    {
        MazeDataGen gen = new MazeDataGen(height, width);
        return  gen.GenerateNewMaze();
    }

}
